# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=qtbinpatcher
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.2.0
pkgrel=1
pkgdesc="Patcher for Qt libraries (mingw-w64)"
arch=('any')
url="http://tver-soft.org"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-cmake")
options=('staticlibs' 'strip')
source=(${_realname}-${pkgver}.tar.gz::https://github.com/tver-soft/QtBinPatcher/archive/v${pkgver}.tar.gz
        #http://tver-soft.org/dl/${_realname}-${pkgver}.tar.bz2
        001-minimize-files-touching.patch)
sha256sums=('7196199cd59777bf78ee0e3f77baa3c44e02e69dded192d6f0e59cf9b7bbd18e'
            'a1069f33493c5a4da4b42d9d4acf8ab3c26946cd040b7024d29d4eeae4d90ea4')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/001-minimize-files-touching.patch
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p ${srcdir}/build-${MINGW_CHOST}
  cd ${srcdir}/build-${MINGW_CHOST}

  ${MINGW_PREFIX}/bin/cmake \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${pkgdir}${MINGW_PREFIX} \
    -DCMAKE_BUILD_TYPE=Release \
    ../${_realname}-${pkgver}
  make
}

package() {
  cd ${srcdir}/build-${MINGW_CHOST}

  make install
}
